//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.Globalization;
using System.Windows.Data;
using OpenLS.Drawing;
using OpenLS.Spreadsheet.UI.Internals;

namespace OpenLS.Spreadsheet.UI
{
    class TableStyleElementToBackgroundConverter: IMultiValueConverter
    {
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            var element = StrictConverter.Convert<TableStyleElement>( values[0]);
            var colorScheme = StrictConverter.Convert<ColorScheme>(values[1]);
            if (element == null)
                return null;
            if (element.StyleRecord == null)
                return null;
            if (element.StyleRecord.Background == null)
                return null;
            return FillToBrushConverter.GetBrush(element.StyleRecord.Background, colorScheme);
        }

        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
        {
            throw new NotSupportedException();
        }
    }
}
